package com.ruoyi.zxjd.work.service.impl;

import com.ruoyi.common.core.text.Convert;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.common.utils.ShiroUtils;
import com.ruoyi.zxjd.work.domain.WorkProgress;
import com.ruoyi.zxjd.work.domain.WorkTemplateTable5;
import com.ruoyi.zxjd.work.domain.bo.WorkProgressBO;
import com.ruoyi.zxjd.work.mapper.WorkTemplateTable5Mapper;
import com.ruoyi.zxjd.work.service.IWorkTemplateTable5Service;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 市纪委监委信访移送件办理情况登记Service业务层处理
 * 
 * @author lcc
 * @date 2021-03-01
 */
@Service
public class WorkTemplateTable5ServiceImpl implements IWorkTemplateTable5Service 
{
    @Autowired
    private WorkTemplateTable5Mapper workTemplateTable5Mapper;
    @Autowired
    private WorkProgressServiceImpl workProgressService;

    /**
     * 查询市纪委监委信访移送件办理情况登记
     * 
     * @param id 市纪委监委信访移送件办理情况登记ID
     * @return 市纪委监委信访移送件办理情况登记
     */
    @Override
    public WorkTemplateTable5 selectWorkTemplateTable5ById(Long id)
    {
        return workTemplateTable5Mapper.selectWorkTemplateTable5ById(id);
    }

    /**
     * 查询市纪委监委信访移送件办理情况登记列表
     * 
     * @param workTemplateTable5 市纪委监委信访移送件办理情况登记
     * @return 市纪委监委信访移送件办理情况登记
     */
    @Override
    public List<WorkTemplateTable5> selectWorkTemplateTable5List(WorkTemplateTable5 workTemplateTable5)
    {
        return workTemplateTable5Mapper.selectWorkTemplateTable5List(workTemplateTable5);
    }

    /**
     * 新增市纪委监委信访移送件办理情况登记
     * 
     * @param workTemplateTable5 市纪委监委信访移送件办理情况登记
     * @return 结果
     */
    @Override
    public int insertWorkTemplateTable5(WorkProgressBO workProgressBO)
    {
        WorkProgress workProgress = workProgressBO.getWorkProgress();
        workTemplateTable5Mapper.deleteByProgressId(workProgress.getProgressId());
        List<WorkTemplateTable5> WorkTemplateTable5List = workProgressBO.getWorkTemplateTable5List();
        for (WorkTemplateTable5 Table : WorkTemplateTable5List) {
            Table.setCreateBy(ShiroUtils.getLoginName());
            Table.setCreateTime(DateUtils.getNowDate());
            Table.setProgressId(workProgress.getProgressId());
            workTemplateTable5Mapper.insertWorkTemplateTable5(Table);
        }
        return workProgressService.validate(workProgress);
    }

    /**
     * 修改市纪委监委信访移送件办理情况登记
     * 
     * @param workTemplateTable5 市纪委监委信访移送件办理情况登记
     * @return 结果
     */
    @Override
    public int updateWorkTemplateTable5(WorkTemplateTable5 workTemplateTable5)
    {
        workTemplateTable5.setUpdateBy(ShiroUtils.getLoginName());
        workTemplateTable5.setUpdateTime(DateUtils.getNowDate());
        return workTemplateTable5Mapper.updateWorkTemplateTable5(workTemplateTable5);
    }

    /**
     * 删除市纪委监委信访移送件办理情况登记对象
     * 
     * @param ids 需要删除的数据ID
     * @return 结果
     */
    @Override
    public int deleteWorkTemplateTable5ByIds(String ids)
    {
        return workTemplateTable5Mapper.deleteWorkTemplateTable5ByIds(Convert.toStrArray(ids));
    }

    /**
     * 删除市纪委监委信访移送件办理情况登记信息
     * 
     * @param id 市纪委监委信访移送件办理情况登记ID
     * @return 结果
     */
    @Override
    public int deleteWorkTemplateTable5ById(Long id)
    {
        return workTemplateTable5Mapper.deleteWorkTemplateTable5ById(id);
    }

    /**
     * 查询市纪委监委信访移送件办理情况登记
     * 
     * @param progressId
     * @return 市纪委监委信访移送件办理情况登记
     */
    @Override
    public List<WorkTemplateTable5> selectWorkTemplateTable5ByProgressId(Long progressId)
    {
        return workTemplateTable5Mapper.selectWorkTemplateTable5ByProgressId(progressId);
    }

    /**
     * 查询市纪委监委信访移送件办理情况登记
     * 
     * @param arrangeId
     * @return 市纪委监委信访移送件办理情况登记
     */
    @Override
    public List<WorkTemplateTable5> selectWorkTemplateTable5ByArrangeId(Long arrangeId)
    {
        return workTemplateTable5Mapper.selectWorkTemplateTableByArrangeIdAndStatus(arrangeId);
    }
}
